package game;

import java.io.Serializable;
import java.util.Random;

public class Player implements Serializable{
	private String name;
	private int xpos;
	private int ypos;
	private int point;
	private String direction;
	private Random tempRandom = new Random();

	/**
	 * 
	 * @param name
	 */
	public Player(String name) {
		this.name = name;
		spawn();
		point = 0;
		direction = "up";
	}
	
	public void spawn()
	{
		xpos = tempRandom.nextInt(20);
		ypos = tempRandom.nextInt(20);
		if (Map.getInstance(null).isWall(xpos, ypos))
			spawn();
	}

	public String getName()
	{
		return name;
	}

	/**
	 * 
	 * @return
	 */
	public int getXpos() {
		return xpos;
	}

	/**
	 * 
	 * @param xpos
	 */
	public void setXpos(int xpos) {
		this.xpos = xpos;
	}

	/**
	 * 
	 * @return
	 */
	public int getYpos() {
		return ypos;
	}

	/**
	 * 
	 * @param ypos
	 */
	public void setYpos(int ypos) {
		this.ypos = ypos;
	}

	/**
	 * 
	 * @return
	 */
	public String getDirection() {
		return direction;
	}

	/**
	 * 
	 * @param direction
	 */
	public void setDirection(String direction) {
		this.direction = direction;
	}

	/**
	 * 
	 */
	@Override
	public String toString() {
		return name + "   " + point;
	}

	/**
	 * 
	 */
	void addOnePoint() {
		point++;
	}

	/**
	 * 
	 */
	void subOnePoint() {
		point--;
	}
}
